<?php
add_filter("mce_buttons_3", "enable_more_buttons");
function enable_more_buttons($buttons) {
  $buttons[] = 'hr';
  $buttons[] = 'sub';
  $buttons[] = 'sup';
  $buttons[] = 'fontselect';
  $buttons[] = 'fontsizeselect';
  $buttons[] = 'styleselect';
  return $buttons;
}

/* Using TwentyEleven Comments function */
function TecBridge_comment( $comment, $args, $depth ) {
	$GLOBALS['comment'] = $comment;
	switch ( $comment->comment_type ) :
		case 'pingback' :
		case 'trackback' :
	?>
	<li class="post pingback">
		<p><?php _e( 'Pingback:', 'TecBridge' ); ?> <?php comment_author_link(); ?><?php edit_comment_link( __( 'Edit', 'TecBridge' ), '<span class="edit-link">', '</span>' ); ?></p>
	<?php
			break;
		default :
	?>
	<li <?php comment_class(); ?> id="li-comment-<?php comment_ID(); ?>">
		<article id="comment-<?php comment_ID(); ?>" class="comment">
			<footer class="comment-meta">
				<div class="comment-author vcard">
					<?php
						$avatar_size = 68;
						if ( '0' != $comment->comment_parent )
							$avatar_size = 39;

						echo get_avatar( $comment, $avatar_size );

						/* translators: 1: comment author, 2: date and time */
						printf( __( '%1$s on %2$s <span class="says">said:</span>', 'TecBridge' ),
							sprintf( '<span class="fn">%s</span>', get_comment_author_link() ),
							sprintf( '<a href="%1$s"><time pubdate datetime="%2$s">%3$s</time></a>',
								esc_url( get_comment_link( $comment->comment_ID ) ),
								get_comment_time( 'c' ),
								/* translators: 1: date, 2: time */
								sprintf( __( '%1$s at %2$s', 'TecBridge' ), get_comment_date(), get_comment_time() )
							)
						);
					?>

					<?php edit_comment_link( __( 'Edit', 'TecBridge' ), '<span class="edit-link">', '</span>' ); ?>
				</div><!-- .comment-author .vcard -->

				<?php if ( $comment->comment_approved == '0' ) : ?>
					<em class="comment-awaiting-moderation"><?php _e( 'Your comment is awaiting moderation.', 'TecBridge' ); ?></em>
					<br />
				<?php endif; ?>

			</footer>

			<div class="comment-content"><?php comment_text(); ?></div>

			<div class="reply">
				<?php comment_reply_link( array_merge( $args, array( 'reply_text' => __( 'Reply <span>&darr;</span>', 'TecBridge' ), 'depth' => $depth, 'max_depth' => $args['max_depth'] ) ) ); ?>
			</div><!-- .reply -->
		</article><!-- #comment-## -->

	<?php
			break;
	endswitch;
}

function content_nav( $nav_id, $string = 'posts' ) {
	global $wp_query;

	if ( $wp_query->max_num_pages > 1 ) : ?>
		<nav id="<?php echo $nav_id; ?>">
			<div class="nav-previous"><?php next_posts_link( __( '<span class="meta-nav">&larr;</span> Older '. $string, 'TecBridge' ) ); ?></div>
			<div class="nav-next"><?php previous_posts_link( __( 'Newer ' . $string . '<span class="meta-nav">&rarr;</span>', 'TecBridge' ) ); ?></div>
		</nav><!-- #nav-above -->
	<?php endif;
}

add_filter('pre_get_posts','SearchFilter');
function SearchFilter($query) {
	if ($query->is_search) {
		$query->set('post_type', array('post', 'products'));
	}
	return $query;
}

add_filter('widget_text', 'do_shortcode');

add_action( 'widgets_init', 'sidebars' );
function sidebars() {
	register_sidebar( array(
		'name' => __( 'Header WidgetArea', 'TecBridge' ),
		'id' => 'header_widgetarea',
		'before_widget' => '<aside id="%1$s" class="widget %2$s">',
		'after_widget' => "</aside>",
		'before_title' => '<h3 class="widget-title">',
		'after_title' => '</h3>',
	) );
	register_sidebar( array(
		'name' => __( 'Footer WidgetArea', 'TecBridge' ),
		'id' => 'footer_widgetarea',
		'before_widget' => '<aside id="%1$s" class="widget %2$s">',
		'after_widget' => "</aside>",
		'before_title' => '<h3 class="widget-title">',
		'after_title' => '</h3>',
	) );
}

add_action( 'init', 'register_my_menu' );
function register_my_menu() {
	register_nav_menus( array(
	  'primary-menu' => __( 'Primary Navigation', 'TecBridge' ) ) );
}


add_action( 'init', 'create_post_type' );
function create_post_type() {
	register_post_type( 'casestudy',
		array(
			'labels' => array(
				'name' => __( 'Case Study' ),
				'singular_name' => __( 'Case Study' )
			),
		'public' => true,
		'has_archive' => true,
		)
	);
	register_post_type( 'biography',
		array(
			'labels' => array(
				'name' => __( 'Biography' ),
				'singular_name' => __( 'Biography' )
			),
		'public' => true,
		'has_archive' => true,
		)
	);
	register_post_type( 'products',
		array(
			'labels' => array(
				'name' => __( 'Products' ),
				'singular_name' => __( 'Products' )
			),
		'public' => true,
		'has_archive' => true,
		)
	);
	register_post_type( 'contact',
		array(
			'labels' => array(
				'name' => __( 'Contact Info' ),
				'singular_name' => __( 'Contact Info' )
			),
		'public' => true,
		'has_archive' => true,
		)
	);
}

function catch_that_image($default='') {
	global $post, $posts;
	$first_img = '';
	ob_start();
	ob_end_clean();
	$output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $post->post_content, $matches);
	if (empty($matches[1][0]))
		if (empty($default))
			$first_img = false;
		else
			$first_img = $default;
	else
		$first_img = $matches [1] [0];

	return $first_img;
}

function is_market_related() {
	if ('products' == get_post_type() || is_page_template('page-market.php'))
		return true;
	
	return false;

}
$small = true;
?>